<!--
 * @Author: Cenven
 * @Date: 2021-02-24 15:33:45
 * @Description: 北京泓深教育发展有限公司
 * @Descripttion: 
 * @version: @Lastest
 * @LastEditTime: 2021-07-21 17:15:24
 * @CopyRight: 北京泓深教育发展有限公司
-->
<template>
  <div class="component__order_card" @click="toPath(detail)">
    <div :class="['course-box']">
      <div :class="['card_left', kl_md.KLGL == 1 ? 'gelin-card' : '']">
        <img v-lazy="detail.course.iconPath" :key="detail.course.iconPath" />
      </div>
      <div :class="['card_right', kl_md.KLGL == 1 ? 'gelin-card' : '']">
        <div class="card-title">{{ detail.course.courseName }}</div>
        <div class="card-info">
          <div class="card-info-right">
            <template v-if="!is_show_price && !is_hidden_content">
              <div>
                <span class="oldprice"
                  ><span class="coursedot">&yen;</span
                  >{{ detail.course.price }}</span
                >
                <span class="price"
                  ><span class="coursedot">&yen;</span
                  >{{ detail.groupPurchaseGoods.lastMoney }}</span
                >
              </div>
            </template>
          </div>
        </div>
        <div class="card-info">
          <div class="status-ctn">
            <div class="group-user">
              <template v-if="detail && detail.userList">
                <div
                  class="user-item"
                  v-for="(item, index) in detail.userList"
                  :key="'component__order_card' + index"
                >
                  <div class="item-ctn">
                    <img
                      class="user-avatar"
                      v-lazy="item && item.avatar"
                      v-if="item && item.avatar"
                      :key="item && item.avatar"
                    />
                    <span v-if="item && !item.avatar" class="avatar-alt">
                      {{ item.acName && item.acName.substring(0, 1) }}
                    </span>
                  </div>
                </div>
              </template>
            </div>
            <span class="status" v-if="detail.status == 1">
              正在拼单
            </span>
            <span class="status" v-else-if="detail.status == 2">
              已拼单
            </span>
            <span class="status" v-else-if="detail.status == 3">
              已过期
            </span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  props: ["detail"],
  data() {
    return {
      
    };
  },
  computed: {
    ...mapState({
      is_ios(state) {
        return state.is_ios;
      },
      is_in_wechat(state) {
        return state.is_in_wechat;
      },
      member_discount(state) {
        return state.member_discount;
      },
      is_hidden_content(state) {
        return state.is_hidden_content;
      },
      kl_md(state) {
        return state.kl_md;
      },
      is_wechat_ios_limit(state) {
        return state.is_wechat_ios_limit;
      }
    }),

    isMemberFree() {
      // console.log("member_discount",this.memberDiscount)
      if (this.memberDiscount && JSON.stringify(this.memberDiscount) !== "{}") {
        if (
          this.memberDiscount.majorIds.includes(this.detail.majorId) ||
          this.memberDiscount.courseIds.includes(this.detail.id)
        ) {
          return true;
        } else {
          return false;
        }
      }
    },
    is_show_price() {
      if (this.is_wechat_ios_limit) {
        return this.is_ios && this.is_in_wechat;
      } else {
        return false;
      }
    }
  },
  watch: {},
  methods: {
    // toPath(detail) {
    //   console.log("进来了",detail)
    //   if (this.type == "bought") {
    //     this.$router.push({
    //       path: "/m/course-detail",
    //       query: {
    //         id: detail.courseId
    //       }
    //     });
    //   } else {
    //     this.$router.push({
    //       path: "/m/course-detail",
    //       query: {
    //         id: detail.id
    //       }
    //     });
    //   }
    // }
    toPath(item) {
      const id = item.course && item.course.id;
      this.$router.push({
        path: "/m/course-detail",
        query: {
          id
        }
      });
    }
  },
  created() {
    console.log(this.detail);
  },
  mounted() {}
};
</script>

<style lang="scss" scoped>
.component__order_card {
  width: 6.8rem;
  box-sizing: content-box;
  padding: 0 0.2rem;
  .course-box {
    position: relative;
    display: flex;
    align-items: center;
    overflow: hidden;
    width: 100%;
    height: 1.8rem;
    .card_left {
      width: 2.72rem;
      border-radius: 0.04rem;
      overflow: hidden;
      position: relative;
      .card-tag {
        position: absolute;
        top: 0.1rem;
        left: 0;
        font-size: 0.16rem;
      }
      img {
        width: 100%;
        // width: 3.75rem;
        height: 1.8rem;
        display: block;
        // background: aqua;
      }
    }
    .card_left.gelin-card {
      width: 1.35338rem;
    }
    .card_right {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      box-sizing: border-box;
      // padding: .1rem .2rem;
      padding: 0 0 0 0.2rem;
      height: 100%;
      .card-title {
        // font-size: .3rem;
        // font-size: .24rem;
        font-size: 0.2688rem;
        height: 0.8rem;
        line-height: 0.4rem;
        color: #494a4d;
        font-weight: bold;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        overflow: hidden;
        text-overflow: ellipsis;
        -webkit-box-orient: vertical;
      }
      .card_label {
        font-size: 0.26rem;
        line-height: 0.5rem;
        height: 0.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .card-info {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 0.24rem;
        .card-info-left {
          display: flex;
          align-items: center;
          color: #adafb3;
          img {
            width: 0.4rem;
            height: 0.4rem;
            display: block;
          }
        }
        .card-info-right {
          // font-size: .34rem;
          font-family: "微软雅黑", arial, "\5b8b\4f53";
          color: var(--theme-color);
          // font-family: -apple-system,BlinkMacSystemFont,Microsoft YaHei UI,Microsoft YaHei,Roboto,Hiragino Sans GB,Source Han Sans CN,Fira Sans,Droid Sans,Helvetica Neue,arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
          .coursedot {
            // font-size: .26rem;
            margin-right: 0.06rem;
          }
          .price {
          }
          .oldprice {
            color: #666;
            position: relative;
          }
          .oldprice::before {
            content: "";
            display: block;
            position: absolute;
            left: -5%;
            top: 50%;
            transform: translateY(-50%);
            width: 110%;
            height: 0.02rem;
            background: #666;
          }
        }
        .status-ctn {
          display: flex;
          align-items: flex-end;
          width: 100%;
          .group-user {
            flex: 1;
            display: flex;
            flex-wrap: nowrap;
            overflow: hidden;
            .user-item {
              width: 0.4rem;
              overflow: visible;
              .item-ctn {
                display: flex;
                align-items: center;
                justify-content: center;
                width: 0.5rem;
                height: 0.5rem;
                border-radius: 0.5rem;
                background-color: var(--theme-color);
                font-size: 0.24rem;
                overflow: hidden;
                border: 0.01rem solid var(--theme-color-lighter);
              }
              .user-avatar {
                width: 100%;
                height: 100%;
              }
              .avatar-alt {
                color: #fff;
              }
            }
          }
          .status {
            color: var(--theme-color);
            font-size: 0.26rem;
          }
        }
      }
    }
    .card_right.gelin-card {
      width: 5.4rem;
    }
    .tags {
      position: absolute;
      right: 0;
      top: 0;
    }
    .card-img {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 2.52rem;
      height: 1.73rem;
      margin-right: 0.2rem;
      overflow: hidden;
      border-radius: 0.08rem;
      background-color: #e5e5e5;
      img {
        width: 100%;
        height: auto;
      }
    }
    .card-content {
      flex: 1;
      // display: flex;
      // flex-direction: column;
      overflow: hidden;
      .card-title {
        // margin-top: 0.1rem;
        margin-top: 0.3rem;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
        min-height: 0.7rem;
        font-size: 0.26rem;
        color: #010101;
        line-height: 0.35rem;
      }
      .line {
        &::before {
          content: "";
          width: 0.02rem;
          height: 0.2rem;
          background-color: #ddd;
          display: inline-block;
          vertical-align: -0.02rem;
          margin: 0 0.1rem 0 0.03rem;
        }
      }
      .card-info {
        margin-top: 0.15rem;
        font-size: 0.21rem;
        line-height: 0.21rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: #101010;
        i {
          vertical-align: text-bottom;
          margin-right: 0.05rem;
          font-size: 0.3rem;
          color: var(--theme-color);
        }
      }
      .card-info-line {
        margin-top: 0.2rem;
        display: flex;
        .line-item {
          display: flex;
          align-items: center;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          &:last-child {
            flex: 1;
          }
        }
        .line-item + .line-item {
          margin-left: 0.1rem;
        }
        .price {
          color: #f0423d;
          font-size: 0.26rem;
          justify-content: flex-end;
          font-weight: 700;
          .price-market {
            margin-right: 0.08rem;
            color: #666;
            font-weight: 400;
            font-size: 0.18rem;
            text-decoration: line-through;
            text-align: right;
            vertical-align: text-bottom;
            line-height: normal;
          }
        }
        .price-free {
          color: #4fc08d;
          font-weight: 400;
        }
      }
      .card-info2 {
        flex: 1;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
        font-size: 0.22rem;
        line-height: 0.3rem;
        max-height: 0.6rem;
        color: #666;
      }
    }
  }
  .course-box.bottom {
    border-bottom: solid 0.02rem #ededf1;
  }
}
// .component__course_card + .component__course_card {
//   margin-top: 0.1rem;
// }
</style>
<style lang="scss">
.component__course_card {
  .card-img {
    position: relative;
    .card-tag {
      position: absolute;
      top: 0.1rem;
      left: 0;
      font-size: 0.16rem;
    }
  }
}
</style>
